import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    isLoading: false
  },
  mutations: {
    openLoading: function (state) {
      state.isLoading = true;
    },
    closeLoading: function (state) {
      state.isLoading = false;
    }
  },
  getters: {
    getLoading(state) {
      return state.isLoading;
    }
  },
  actions: {
    loadingStart({ commit }) {
      commit("openLoading");
    },
    loadingEnd({ commit }) {
      commit("closeLoading");
    }
  },
  modules: {}
});
